<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::DSL::BehaviourFactory</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::DSL::BehaviourFactory</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/dsl/behaviour_factory_rb.html">
                vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000329">add_behaviour_class</a>&nbsp;&nbsp;
      <a href="#M000331">create</a>&nbsp;&nbsp;
      <a href="#M000330">remove_behaviour_class</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">BEHAVIOUR_CLASSES</td>
          <td>=</td>
          <td class="context-item-value">{:default =&gt; Spec::DSL::Behaviour}</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000329" class="method-detail">
        <a name="M000329"></a>

        <div class="method-heading">
          <a href="#M000329" class="method-signature">
          <span class="method-name">add_behaviour_class</span><span class="method-args">(behaviour_type, klass)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Registers a behaviour class <tt>klass</tt> with the symbol
<tt>behaviour_type</tt>. For example:
</p>
<pre>
  Spec::DSL::BehaviourFactory.add_behaviour_class(:farm, Spec::Farm::DSL::FarmBehaviour)
</pre>
<p>
This will cause <a href="../../Kernel.html#M000369">Kernel#describe</a>
from a file living in <tt>spec/farm</tt> to <a
href="BehaviourFactory.html#M000331">create</a> behaviour instances of type
Spec::Farm::DSL::FarmBehaviour.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000329-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000329-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb, line 17</span>
17:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_behaviour_class</span>(<span class="ruby-identifier">behaviour_type</span>, <span class="ruby-identifier">klass</span>)
18:           <span class="ruby-constant">BEHAVIOUR_CLASSES</span>[<span class="ruby-identifier">behaviour_type</span>] = <span class="ruby-identifier">klass</span>
19:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000331" class="method-detail">
        <a name="M000331"></a>

        <div class="method-heading">
          <a href="#M000331" class="method-signature">
          <span class="method-name">create</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000331-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000331-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb, line 25</span>
25:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
26:           <span class="ruby-identifier">opts</span> = <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-value">? </span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">:</span> {}
27:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:shared</span>]
28:             <span class="ruby-identifier">behaviour_type</span> = <span class="ruby-identifier">:default</span>
29:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:behaviour_type</span>]
30:             <span class="ruby-identifier">behaviour_type</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:behaviour_type</span>]
31:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:spec_path</span>] <span class="ruby-operator">=~</span> <span class="ruby-node">/spec(\\|\/)(#{BEHAVIOUR_CLASSES.keys.join('|')})/</span>
32:             <span class="ruby-identifier">behaviour_type</span> = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_sym</span>
33:           <span class="ruby-keyword kw">else</span>
34:             <span class="ruby-identifier">behaviour_type</span> = <span class="ruby-identifier">:default</span>
35:           <span class="ruby-keyword kw">end</span>
36:           <span class="ruby-keyword kw">return</span> <span class="ruby-constant">BEHAVIOUR_CLASSES</span>[<span class="ruby-identifier">behaviour_type</span>].<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
37:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000330" class="method-detail">
        <a name="M000330"></a>

        <div class="method-heading">
          <a href="#M000330" class="method-signature">
          <span class="method-name">remove_behaviour_class</span><span class="method-args">(behaviour_type)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000330-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000330-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/behaviour_factory.rb, line 21</span>
21:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_behaviour_class</span>(<span class="ruby-identifier">behaviour_type</span>)
22:           <span class="ruby-constant">BEHAVIOUR_CLASSES</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">behaviour_type</span>)
23:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>